clear()
axesOn()
gridOn()

def drawRegularPolygon(side:Int,length:Int):Unit= {
    turtle0.invisible()
    turtle0.setAnimationDelay(3)
    turtle0.penUp()
    turtle0.moveTo(-findRadius(side,length),0)
    turtle0.right(90+(180.0/side))
    turtle0.penDown()
    var i=1
    Staging.circle(0, 0, findRadius(side,length))
    Staging.circle(0, 0, findInRadius(side,length))
    while(i<=side) {
        turtle0.forward(length)
        Staging.setPenColor(blue)
        Staging.setPenThickness(5)
        Staging.dot(turtle0.position)
        turtle0.right(360.0/side)
        i+=1
    }
}
drawRegularPolygon(4,100)

def rads(degree:Double) = (degree *Math.Pi)/180

def findRadius(side:Int,length:Double) = (length/2.0)* 1.0/(Math.sin(Math.Pi/side))
def findInRadius(side:Int,length:Double) = (length/2.0)* 1.0/(Math.tan(Math.Pi/side))

